<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>原生JS</title>
    <link href="https://cdn.bootcdn.net/ajax/libs/twitter-bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
</head>

<body>
    <div class="container">
        <table id="friends" class="table table-striped">
            <thead>
                <tr>
                    <th>姓名</th>
                    <th>年龄</th>
                </tr>
            </thead>
            <!-- 挂载点 -->
            <tbody>
                <tr>
                    <td>张三</td>
                    <td>18</td>
                </tr>
            </tbody>
        </table>
    </div>

    <script>
        // 挂载点 html 有js 动态生成
        const tbody = document.querySelector('#friends tbody');
        // JSON 数组
        // DOM 编程 动态页面 数据
        const friends = [
            { name: '张三', age: 18 },
            { name: '李四', age: 20 },
            { name: '王五', age: 22 }
        ];
        // html 字符串 = 数组 类型转换
        tbody.innerHTML = friends.map(friend =>
            `<tr>
            <td>${friend.name}</td>
            <td>${friend.age}</td>
        </tr>`
        ).join('');
    </script>
</body>

</html>